package com.aaa.service.impl;

import com.aaa.common.domain.ContractInfo;
import com.aaa.common.query.ConditionalQuery;
import com.aaa.common.query.PageQuery;
import com.aaa.common.result.Result;
import com.aaa.mapper.OtherAssetsContractInfoMapper;
import com.aaa.service.OtherAssetsContractInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 宋文森
 * @Date: 2021/02/03/21:32
 * @Description: 其他资产出租合同服务实习类
 */
@Service
public class OtherAssetsContractServiceImpl implements OtherAssetsContractInfoService {

    @Autowired
    private OtherAssetsContractInfoMapper otherAssetsContractInfoMapper;

    public Result listAll(PageQuery pageQuery) {
        Page<ContractInfo> contractInfoPage = new Page<>(pageQuery.getCurrentPage(),pageQuery.getPageCount());
        Page<ContractInfo> contractInfos = otherAssetsContractInfoMapper.listContract(contractInfoPage);
        if (contractInfos!=null){
            return Result.success(contractInfos);
        }
        return Result.error("其他资产出租合同信息查询失败");
    }

    public Result conditionalQuery(ConditionalQuery conditionalQuery) {
        Page<ContractInfo> contractInfoPage = new Page<>(conditionalQuery.getCurrentPage(),conditionalQuery.getPageCount());
        Page<ContractInfo> contractInfos = otherAssetsContractInfoMapper.conditionalQuery(contractInfoPage,conditionalQuery.getContractId(),conditionalQuery.getAssetId(),conditionalQuery.getLessee(),conditionalQuery.getCompanyName(),conditionalQuery.getContractStatusId());
        if (contractInfos!=null){
            return Result.success(contractInfos);
        }
        return Result.error("其他资产出租合同信息条件查询失败");
    }
}
